DEFINITION MODULE ToolboxMisc;   (* Christoph Fleischer 07.02.85 *)
                                 (* MacIntosh Toolbox General Utilities *)
                                 (* last modification   06.08.85 fxk *)

FROM SYSTEM IMPORT ADDRESS;
FROM MacBase IMPORT LongInt,Handle,OsErr,StrPtr;

EXPORT QUALIFIED
  StringHandle,Fixed,Int64Bit,
  BitAnd,BitOr,BitXor,BitNot,BitShift,BitTst,BitSet,BitClr,LongMul,FixMul,FixRatio,HiWord,LoWord,FixRound,
  PackBits,UnPackBits,HandToHand,PtrToXHand,PtrToHand,HandAndHand,PtrAndHand,NewString,SetString,
  GetString,Munger;

TYPE
  StringHandle = POINTER TO StrPtr;
  Fixed        = LongInt;
  Int64Bit     = RECORD
                   hiLong: LongInt;
                   loLong: LongInt;
                 END;

PROCEDURE BitAnd   (long1,long2: LongInt): LongInt;               (*INLINE $A858*)
PROCEDURE BitOr    (long1,long2: LongInt): LongInt;               (*INLINE $A85B*)
PROCEDURE BitXor   (long1,long2: LongInt): LongInt;               (*INLINE $A859*)
PROCEDURE BitNot   (long: LongInt): LongInt;                      (*INLINE $A85A*)
PROCEDURE BitShift (long: LongInt; count: INTEGER): LongInt;      (*INLINE $A85C*)
PROCEDURE BitTst   (bytePtr: ADDRESS; bitNum: LongInt): BOOLEAN;      (*INLINE $A85D*)
PROCEDURE BitSet   (bytePtr: ADDRESS; bitNum: LongInt);               (*INLINE $A85E*)
PROCEDURE BitClr   (bytePtr: ADDRESS; bitNum: LongInt);               (*INLINE $A85F*)
PROCEDURE LongMul  (a,b: LongInt; VAR dst: Int64Bit);             (*INLINE $A867*)
PROCEDURE FixMul   (a,b: Fixed): Fixed;                           (*INLINE $A868*)
PROCEDURE FixRatio (numer,denom: INTEGER): Fixed;                 (*INLINE $A869*)
PROCEDURE HiWord   (x: Fixed): INTEGER;                           (*INLINE $A86A*)
PROCEDURE LoWord   (x: Fixed): INTEGER;                           (*INLINE $A86B*)
PROCEDURE FixRound (x: Fixed): INTEGER;                           (*INLINE $A86C*)
PROCEDURE PackBits (VAR srcPtr,dstPtr: ADDRESS; srcBytes: INTEGER);   (*INLINE $A8CF*)
PROCEDURE UnPackBits(VAR srcPtr,dstPtr: ADDRESS; dstBytes: INTEGER);  (*INLINE $A8D0*)

PROCEDURE HandToHand(VAR theHndl: Handle): OsErr;
PROCEDURE PtrToXHand(srcPtr: ADDRESS; dstHndl: Handle; size: LongInt): OsErr;
PROCEDURE PtrToHand(srcPtr: ADDRESS; VAR dstHndl: Handle; size: LongInt): OsErr;
PROCEDURE HandAndHand(hand1,hand2: Handle): OsErr;
PROCEDURE PtrAndHand(ptr1: ADDRESS; hand2: Handle; size: LongInt): OsErr;

PROCEDURE NewString(theString:StrPtr): StringHandle;          (*INLINE $A906*)
PROCEDURE SetString(theString:StringHandle;strNew: StrPtr);   (*INLINE $A907*)
PROCEDURE GetString(stringID:  INTEGER): StringHandle;            (*INLINE $A9BA*)

PROCEDURE Munger(h: Handle; offset: LongInt;
                 ptr1: ADDRESS; len1: LongInt;
                 ptr2: ADDRESS; len2: LongInt): LongInt;              (*INLINE $A9E0*)

END ToolboxMisc.
